package com.csweimei.rentmanagementtreasure.pop;

import android.content.Context;
import android.text.Html;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.utils.ValidateUtils;
import com.lxj.xpopup.core.CenterPopupView;

public class WarnPop extends CenterPopupView {

    TextView tvCancel;
    TextView tvSubmit;
    TextView title,content;
    private OnSelCallBack mOnSelCallBack;
    String titles,mcontent,suretext;

    public interface OnSelCallBack {
        void onCallBack(String s);
    }

    public WarnPop(@NonNull Context context, OnSelCallBack onSelCallBack) {
        super(context);
        this.mOnSelCallBack = onSelCallBack;
    }

    public WarnPop(@NonNull Context context, String title, OnSelCallBack onSelCallBack) {
        super(context);
        this.mOnSelCallBack = onSelCallBack;
        this.titles = title;
    }

    public WarnPop(@NonNull Context context, String title, String content, OnSelCallBack onSelCallBack) {
        super(context);
        this.mOnSelCallBack = onSelCallBack;
        this.titles = title;
        this.mcontent = content;
    }


    public WarnPop(@NonNull Context context, String title, String content,String sureText, OnSelCallBack onSelCallBack) {
        super(context);
        this.mOnSelCallBack = onSelCallBack;
        this.titles = title;
        this.mcontent = content;
        this.suretext = sureText;
    }

    @Override
    protected void onCreate() {
        super.onCreate();

        title = findViewById(R.id.title);
        if (ValidateUtils.isNotEmptyString(titles)){
            title.setText(titles);
        }
        content = findViewById(R.id.content);
        if (ValidateUtils.isNotEmptyString(mcontent)){
            content.setText(Html.fromHtml(mcontent));
        }

        tvSubmit = findViewById(R.id.tv_submit);
        tvCancel = findViewById(R.id.tv_cancel);

        tvCancel.setOnClickListener(v -> {
            dismiss();
        });

        if (ValidateUtils.isNotEmptyString(suretext)){
            tvSubmit.setText(suretext);
        }
        tvSubmit.setOnClickListener(v -> {
            mOnSelCallBack.onCallBack("");
            dismiss();

        });

    }


    @Override
    protected int getImplLayoutId() {
        return R.layout.popup_warn;
    }
}
